package com.qixin.web.controller.Car;


import com.qixin.api.bean.ComUserCarRenting;
import com.qixin.api.service.ComUserCarRentingService;
import com.qixin.web.util.SessionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.Date;

/**
 * <p>
 * 用户租车中间表 前端控制器
 * </p>
 *
 * @author 吕正睿
 * @since 2018-11-12
 */
@Controller
@RequestMapping("/comUserCarRenting")
public class ComUserCarRentingController {
	@Autowired
	ComUserCarRentingService comUserCarRentingService;
	/*
	*用户点击租车保存数据
	*
	*
	 */
	@RequestMapping("/rentcar")
	@ResponseBody
	public String rentcar(HttpSession session,Long carId,Long startime,Long endtime,Long number){
		ComUserCarRenting comUserCarRenting=new ComUserCarRenting();
		comUserCarRenting.setUserId(SessionUtil.getUserId(session));
		comUserCarRenting.setCreateTime(new Date().getTime());
		comUserCarRenting.setFlag(SessionUtil.getUserFlag(session));
		comUserCarRenting.setCarId(carId);
		comUserCarRenting.setEndTime(endtime);
		comUserCarRenting.setStarTime(startime);
		comUserCarRenting.setNumber(number);
		return comUserCarRentingService.rentcar(comUserCarRenting);

	}

}
